<link href="/assets/css/ward1.css" type="text/css" rel="stylesheet">
<style type="text/css">
.showhiden { display: none; }
</style>
<input type="hidden" name="matitle" value="{$typeReuslt.typename}" />
<input type="hidden" name="urladdres" value="{$getURL}" />
<input type="hidden" name="randcode" value="{$randcode}" />
<input type="hidden" name="appid" value="{$portinfo['u_appid']}" />
<input type="hidden" name="openid" value="{$Think.cookie.user_userinfo}" />
<input type="hidden" name="getshaddres" value="{$reginfo|count}" />
<input type="hidden" name="userinfoid" value="{$reginfo['id']}">
<script type="text/javascript">
	function changecishu(matype,randcode,userinfoid){
		var send_url = "/Home/Batch/changemacishu";
		var senddata = {"randcode":randcode,"userinfoid":userinfoid,"matype":matype,random:Math.random()};
		$.ajax({
			url:send_url,
			data:senddata,
			type:"POST",
			dataType:"html",
			success:function (data){
				if(data==1){
					if(matype==2){
						alert("信息提交成功，我们会尽快将奖品送出！");
						$(".poplayer").hide();
					}
				}else if(data==0){
					if(matype==2){
						alert("您已领取过此码的奖品");
						$(".poplayer").hide();
					}
				}else{
					alert("error");
				}
			}
		})
	}
</script>
<div class="w ward1">
  <div class="bg-box">
    <div class="video-box"> <img src="/assets/img/ward1/videobg.png" class="video-bg"> 
      <!-- <span><img src="/assets/img/ward1/play.png"></span> -->
      <video width="92%" controls class="video-style">
        <source src="movie.mp4" type="video/mp4">
        您的浏览器不支持 video 标签。 </video>


    <switch name="award.awardkind">
      <case value="2">
      <!--实物奖品开始-->
      <div class="prizes-box" class="wupin">
      <div class="prizes-bg"> <img src="/assets/img/ward1/tag01.png">
        <div class="shiwu"><img src="{$award['awardimg']}"></div>
      </div>
      <div class="prize-btn"> <img src="/assets/img/ward1/btnbg.png"><a class="lingqu">立即领取</a> </div>
    </div>
    <!--填写信息开始-->
    <div class="poplayer">
      <div class="otherinfo float-box" id="floatbox1">
        <div class="title02-pic"><img src="/assets/img/ward1/title02.png"></div>
        <!--有注册过-->
        <if condition="$reginfo|count neq 0">
          <div class="yesreg">
            <div class="input-box">
              <label class="addrestitle">收货地址:</label>
            </div>
            <div class="input-box saddres">
              <input type="radio" name="saddress" value="1" checked>
              <label>{$reginfo['username']} {$reginfo['address']}</label>
              <a id="addresedit">编辑</a> </div>
          </div>
          <elseif condition="$reginfo|count eq 0" />
          <!--没有注册过-->
          <div class="input-information">
            <input type="text" class="inputstyle" name="username" id="username" placeholder="姓名">
            <input type="tel" class="inputstyle" name="usertel" id="usertel" placeholder="手机号">
            <div class="yanzhengma clearfix">
              <input type="number" class="inputstyle2" name="userpass" id="userpass" placeholder="填写验证码">
              <input type="button" class="button-btn" name="jishi" id="jishi" value="获取验证码">
            </div>
            <input type="text" class="inputstyle" name="address" id="address" placeholder="收货地址">
          </div>
        </if>
          <div class="tijiao-btn clearfix">
            <button type="button" class="button-btn2" id="sure-btn">提交</button>
            <a class="cancel-btn">取消</a>
          </div>
      </div>
    </div>
<script type="text/javascript">
$(function(){
	var openid = $("input[name='openid']").val();
	var randcode = $("input[name='randcode']").val();
	var matitle = $("input[name='matitle']").val();
	$(".lingqu").click(function(event) {
		$(".poplayer").fadeIn();
	})
	$(".cancel-btn").click(function(event) {
		$(".poplayer").fadeOut();
		event.stopPropagation();
	})
	$(".float-box").each(function(index, element) {
		$(this).click(function(event){
			event.stopPropagation();
		})
	})
	$(".poplayer").click(function(event) {
		$(".float-box2").fadeOut();
		$(this).fadeOut();
		event.stopPropagation();
	})

	/*发送手机验证码*/
	$("#jishi").click(function(){
		var mobile = $("input[name='usertel']").val();
		var reg = /^0?1[3|4|5|8|7][0-9]\d{8}$/;
		if (!reg.test(mobile)) {
			alert("请输入正确的手机号码！");
			$("input[name='usertel']").val(null);
			$("input[name='usertel']").focus();
			return false;
		}else{
			//先判断是否有注册信息
			var savetel_url = "/Home/Batch/isreginfo";
			var teldata = {"usertel":mobile,random:Math.random()};
			$.ajax({
				url:savetel_url,
				data:teldata,
				type:"POST",
				dataType:"html",
				success:function (data){
					if(data==0){
						var jis = $("input[name='jishi']");
						jis.attr('disabled','disabled');
						var send_url = "/Home/Batch/verifynote";
						var senddata = {"usertel":mobile,random:Math.random()};
						$.ajax({
							url:send_url,
							data:senddata,
							type:"POST",
							dataType:"html",
							success:function (data){
							}
						});
						$("input[name='userpass']").focus();
						settime();
					}
				}
			});
		}
	})

	//倒计时
	var countdown = 30;
	function settime() {
		if (countdown == 0) {
			$("#jishi").val("获取验证码");
			$("#jishi").removeAttr('disabled');
			countdown = 30;
			return;
		} else {
			$("#jishi").val("重新发送("+countdown+")");
			countdown--;
		}
		setTimeout(function() {
		settime()
		},1000)
	}

	/*保存注册信息*/
	$("#sure-btn").click(function(){
		var rootid = '{$rootid}';
		var userpass = $("input[name='userpass']").val();
		var mobile = $("input[name='usertel']").val();
		var username = $("input[name='username']").val();
		var address = $("input[name='address']").val();
		var saddress = $("input[name='saddress']").val();
		if(saddress==1){
			$(this).removeClass('sure-btn');
			var userinfoid = $("input[name='userinfoid']").val();
			/*改变此码的领取记录*/
			addreginfos(rootid,"{$reginfo['tel']}",openid,randcode,"{$reginfo['username']}","{$reginfo['address']}");
			//changecishu(2,randcode,userinfoid);
		}else{
			if($.trim(username)==''){
				alert('请填写姓名！');
				return false;
			}
			if($.trim(address)==''){
				alert('请填写收货地址！');
				return false;
			}
			$(this).removeClass('sure-btn');
			var vget_url = "/Home/Batch/getverifynote";
			var vdata = {"userpass":userpass,random:Math.random()};
			$.ajax({
				url:vget_url,
				data:vdata,
				type:"POST",
				dataType:"html",
				success:function (data){
					/*判断验证码是否正确*/
					if(data==1){
						/*手机验证通过*/
						addreginfos(rootid,mobile,openid,randcode,username,address);
					}else{
						alert("验证不正确，请重新获取！");
						return false;
					}
				}
			});
		}
	})

	//保存信息
	function addreginfos(rootid,mobile,openid,randcode,username,address){
		var send_url = "/Home/Batch/addresreg";
		var senddata = {"rootid":rootid,"usertel":mobile,"openid":openid,"randcode":randcode,"username":username,"address":address,random:Math.random()};
		$.ajax({
			url:send_url,
			data:senddata,
			type:"POST",
			dataType:"html",
			success:function (data){
				if(data>0){
					/*改变此码的领取记录*/
					changecishu(2,randcode,data);
					$(".otherinfo input").each(function(index,element){
						$(this).val(null);
					})
				}else{
					alert("提交失败，请重新填写！");
					$(".otherinfo input").each(function(index,element){
						$(this).val(null);
					})
				}
			}
		});
	}

})
</script> 
    <!--填写信息结束--> 
    <!--实物奖品结束-->
    </case>
    <case value="3"> 
      <!--红包奖品开始--> 
		<div class="prizes-box" class="rmb">
			<div class="prizes-bg" style="margin-bottom:10px;">
				<img src="/assets/img/ward1/tag02.png">
				<em class="hbnum">发送中...</em>
				<i>RMB</i>
			</div>
			<em class="text-content">红包已下发到您的微信中，返回微信聊天列表页，点击置顶消息，领取红包。</em>
		</div>  
		<script type="text/javascript">
		$(function(){
			var openid = $("input[name='openid']").val();
			var randcode = $("input[name='randcode']").val();
			var matitle = $("input[name='matitle']").val();
			checkwardget(randcode);

			//判断此码的奖品是否被领取
			function checkwardget(randcode){
				var send_url = "/Home/Batch/ischeckawardget";
				var senddata = {"randcode":randcode,random:Math.random()};
				$.ajax({
					url:send_url,
					data:senddata,
					type:"POST",
					dataType:"html",
					success:function (data){
						if(data==1){
							alert("此奖品已被人领取！");
							$(".hbnum").html('已领');
							return false;
						}else{
							gethb();
						}
					}
				});
			}
			//恭喜您获得红包,发红包
			function gethb(){
				var appid = $("input[name='appid']").val();
				insertdata(openid,appid,randcode);

			}
			//插入数据库
			function insertdata(getopenid,appid,randcode){
				var rootid = '{$rootid}';
				var getdata_url = "{:U('sendhb')}";
				var data = {"randcode":randcode,"rootid":rootid,"appid":appid,random:Math.random()};
				$.ajax({
					url:getdata_url,
					data:data,
					type:"post",
					dataType:"html",
					success:function (val){
							if(val!=-1 && val!=-2 && val!=-3){
								//红包发送成功后
								$(".hbnum").html(val);
								changecishu(3,randcode,getopenid);
							}else if(val==-1 || val!=-2 || val!=-3){
								alert("红包已抢完！");
								return false;
							}
					},
					error:function(val){
						alert('请求失败！');
					}
				});
			}


		})
		</script>
      <!--红包奖品结束--> 
    </case>
    <case value="1">
    <!--华人钻奖品开始--> 
	<div class="prizes-box" class="hrz">
		<div class="prizes-bg">
			<img src="/assets/img/ward1/tag02.png">
			<em class="dirllem">-</em>
			<i>华人钻</i>
		</div>
		<div class="prize-btn">
			<img src="/assets/img/ward1/btnbg.png">
			<a href="http://hrshop.hrtv.cn/">立即使用</a>
		</div>
	</div>
	<script type="text/javascript">
	$(function(){
		var openid = $("input[name='openid']").val();
		var randcode = $("input[name='randcode']").val();
		var matitle = $("input[name='matitle']").val();
		checkwardget(randcode);

		//判断此码的奖品是否被领取
		function checkwardget(randcode){
			var send_url = "/Home/Batch/ischeckawardget";
			var senddata = {"randcode":randcode,random:Math.random()};
			$.ajax({
				url:send_url,
				data:senddata,
				type:"POST",
				dataType:"html",
				success:function (data){
					if(data==1){
						alert("此奖品已被人领取！");
						return false;
					}else{
						getdrill("来自"+matitle+"的抽奖获得",randcode);
					}
				}
			});
		}
		//恭喜您获得华人钻石,添加到账户
		function getdrill(bodystr,randcode){
			var diamond = getrandom(5,10);
			var savetel_url = "/Home/Batch/adddrill";
			var teldata = {"diamond":diamond,"bodystr":bodystr,random:Math.random()};
			$.ajax({
				url:savetel_url,
				data:teldata,
				type:"POST",
				dataType:"html",
				success:function (data){
					if(data==1){
						$(".dirllem").html(diamond);
						var userinfoid = $("input[name='userinfoid']").val();
						changecishu(1,randcode,userinfoid);
						return false;
					}
				}
			});
		}
		//随机产生华人钻数量
		function getrandom(min,max){
			return Math.floor(min+Math.random()*(max-min));
		}
	})
	</script>
    <!--华人钻奖品结束-->
    </switch>
    <if condition="$mashare eq true">
    			<div class="target"></div>
				<div class="table-prize" style="bottom:0px;">
					<!--游戏区域开始-->
					<table border="0" cellpadding="0" cellspacing="1">
						<tr>
							<td id="0" style="background:url(/assets/img/ward1/prize-bg.png) no-repeat;background-size:cover;">
								<div class="prizepic">
									<img src="/assets/img/ward1/prize08.png">
								</div>
								<i class="xinxi">手机</i>
							</td>
							<td id="1" style="background:url(/assets/img/ward1/prize-bg.png) no-repeat;background-size:cover;">
								<div class="prizepic prizepic02">
									<img src="/assets/img/ward1/prize01.png">
								</div>
								<i class="xinxi">充值卡</i>
							</td>
							<td id="2" style="background:url(/assets/img/ward1/prize-bg.png) no-repeat;background-size:cover;">
								<div class="prizepic prizepic02">
									<img src="/assets/img/ward1/prize02.png">
								</div>
								<i class="xinxi">现金红包</i>
							</td>
						</tr>
						<tr>
							<td id="7" style="background:url(/assets/img/ward1/prize-bg.png) no-repeat;background-size:cover;">
								<div class="prizepic prizepic02">
									<img src="/assets/img/ward1/prize03.png">
								</div>
								<i class="xinxi">现金红包</i>
							</td>
							<td colspan="1" rowspan="1" style="text-align:center;position:relative;">
								<div class="button staBtn" onclick="startRun()"><img src="/assets/img/ward1/prizebtn.png"></div>
								<!-- <div class="button czBtn" onclick="init()">重置</div> -->
							</td>
							<td id="3" style="background:url(/assets/img/ward1/prize-bg.png) no-repeat;background-size:cover;">
								<div class="prizepic prizepic02">
									<img src="/assets/img/ward1/prize04.png">
								</div>
								<i class="xinxi">谢谢参与</i>
							</td>
						</tr>
						<tr>
							<td id="6" style="background:url(/assets/img/ward1/prize-bg.png) no-repeat;background-size:cover;">
								<div class="prizepic prizepic02">
									<img src="/assets/img/ward1/prize05.png">
								</div>
								<i class="xinxi">谢谢参与</i>
							</td>
							<td id="5" style="background:url(/assets/img/ward1/prize-bg.png) no-repeat;background-size:cover;">
								<div class="prizepic prizepic02">
									<img src="/assets/img/ward1/prize06.png">
								</div>
								<i class="xinxi">充值卡</i>
							</td>
							<td id="4" style="background:url(/assets/img/ward1/prize-bg.png) no-repeat;background-size:cover;">
								<div class="prizepic prizepic02">
									<img src="/assets/img/ward1/prize07.png">
								</div>
								<i class="xinxi">华人钻</i>
							</td>
						</tr>
					</table>
				</div>
				<script type="text/javascript">
					$(function(){
						$(".button").click(function(event) {
							$(".target").show()
						});
					})
					
					var n=0;
					init();
					function init(){
						moveToNext(0);
					}
					function moveToNext(i){
						var $target = $('div.target');//代表找到div.target的元素
						var offset = $('#'+(i%8)).offset();
						$target.animate({top:offset.top-34,left:offset.left-9},50);
						//n = i;
					}
					function startRun(){
						var randomNumber = 3;//随机生成0-8之间的数字
						randomNumber = Math.ceil(randomNumber)+50;//+上一个50的基数
						var m = n;
						for(var i=m;i<randomNumber+m;i++){
							moveToNext(i);
						}
					}
				</script>
		    <!--		
			<div class="title-box"><img src="/assets/img/ward1/title03.png"></div>
			<div class="prize-box-list" style="clear:both;">
				<volist name="awardjilu" id="jilu">
				<div class="prize-record clearfix">
					<div class="prize-pic-list clearfix">
						<div class="pic-list">
							<img src="/assets/img/ward1/user-pic.jpg">
						</div>
						<div class="user-in">
							<span>影小轩</span>
							<i>09/19 10:53</i>
						</div>
					</div>
					<em>1000华人钻</em>
				</div>
			    </volist>
			</div>-->
    </if>
  </div>
  <if condition="$mashare neq true">
  <div class="title-box"><img src="/assets/img/ward1/title.png"></div>
  </if>
  <div class="btn-box">
    <div class="btn-list clearfix">
		<a href="http://hrshop.hrtv.cn/" class="shop-btn">华人钻商城</a>
		<a class="zs-btn">防伪追溯</a>
	</div>
    <a href="weixin://contacts/profile/gh_2d5538ffd0f2" class="public-btn">企业公众号</a>
  </div>
</div>
</div>
<include file="share" />